home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / 1svga.zip / HARD2.PAS < prev    next >
Pascal/Delphi Source File  |  1994-05-29  |  2KB  |  49 lines

  1. { Hardware Panning / VGA 320x200,256 Colors }
  2.  
  3. uses SVGA256,Txt;
  4.  
  5. { ─────────────── SetDisplay ─────────────── }
  6. procedure SetDisplay(X,Y:integer);
  7. var A:integer;
  8. begin
  9.   repeat until Port[$3DA] and 8<>8;
  10.   repeat until Port[$3DA] and 8=8;
  11.   A:=80*Y+X shr 2;
  12.   Port[$3D4]:=$0C; Port[$3D5]:=A shr 8;    { Start addr high }
  13.   Port[$3D4]:=$0D; Port[$3D5]:=A and $FF;  { Start addr low }
  14.   repeat until Port[$3DA] and 1<>1;
  15.   repeat until Port[$3DA] and 1=1;
  16.   A:=Port[$3DA];                           { Horizental PEL panning }
  17.   Port[$3C0]:=$13 or $20; Port[$3C0]:=(X mod 4) shl 1;
  18. end;
  19. { ─────────────── Scroll ─────────────── }
  20. procedure Scroll;
  21. var K,K2,X,Y,N:integer;
  22. begin
  23.   SetMode(1);
  24.   Bar(0,0,320,200,1); Box(0,0,320,200,15);
  25.   InstallFont(1,8,16,0,256,8,GetFontAddr(6)^);
  26.   for K:=0 to 21 do Print(150*(K and 1)+20,16*(K shr 1)+10,64+K,
  27.     'Hardware Panning');
  28.   X:=0; Y:=0; K2:=-1; K:=0; N:=3;
  29.   repeat
  30.     SetDisplay(X,Y);
  31.     if KeyPressed=1 then begin K:=Key; if K=K2 then K:=Key; K2:=K; end;
  32.     case K of
  33.       $4B00:Dec(X,N);  $4D00:Inc(X,N);      { Left,Right }
  34.       $4800:Dec(Y,N);  $5000:Inc(Y,N);      { Up,Down }
  35.       $4700:begin Dec(X,N); Dec(Y,N); end;  { Home }
  36.       $4F00:begin Dec(X,N); Inc(Y,N); end;  { End }
  37.       $4900:begin Inc(X,N); Dec(Y,N); end;  { PgUp }
  38.       $5100:begin Inc(X,N); Inc(Y,N); end;  { PgDn }
  39.     end;
  40.     if X<0 then X:=0; if X>319 then X:=319;
  41.     if Y<0 then Y:=0; if Y>199 then Y:=199;
  42.   until (K=$011B) or (K=$1C0D);         { Esc,Enter }
  43.   SetDisplay(1,1); SetMode(1);
  44. end;
  45.  
  46. begin
  47.   Scroll;
  48. end.
  49.